package com.celan.year2022.day1218;

import java.util.Arrays;
import java.util.Scanner;

public class Solution2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] woods = new int[n];
            for (int i = 0; i < n; i++) {
                woods[i] = in.nextInt();
            }
            Arrays.sort(woods);
            int max = 0;
            //5 2
            //4 5 3 5 5->3 4 5 5 5
            while (m > 0) {
                int idx = 1;
                while (woods[idx - 1] >= woods[idx]) {
                    if (idx == n - 1) {
                        idx++;
                        break;
                    }
                    idx++;
                }
                idx--;
                woods[idx]++;
                m--;
                max = Math.max(max, woods[0]);
            }
            System.out.println(max);
        }
    }
}
